﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Payroll.Biz.Legacy.Services
{
    public class ServiceResult
    {
        public bool Success { get; set; }

        public Guid ObjectId { get; set; }

        public object ResultObject { get; set; }

        public string ErrorMessage { get; set; }

        public Exception ErrorException { get; set; }

        public static ServiceResult CreateSuccessResult()
        {
            return new ServiceResult { Success = true };
        }

        public static ServiceResult CreateSuccessResult(Guid objectId)
        {
            return new ServiceResult { Success = true, ObjectId = objectId };
        }

        public static ServiceResult CreateSuccessResult(object resultObject)
        {
            return new ServiceResult { Success = true, ResultObject = resultObject };
        }

        public static ServiceResult CreateErrorResult()
        {
            return new ServiceResult { Success = false };
        }

        public static ServiceResult CreateErrorResult(string errorMessage)
        {
            return new ServiceResult { Success = false, ErrorMessage = errorMessage };
        }

        public static ServiceResult CreateErrorResult(string errorMessage, Exception exception)
        {
            return new ServiceResult { Success = false, ErrorMessage = errorMessage, ErrorException = exception };
        }
    }
}
